<template>
  <div class="layout-header-container">
    <div class="layout-header-left">
      <img 
        class="layout-header-left-img" 
        src="../../assets/logo.png" 
        alt="logo" 
      />
      <h4 class="layout-header-left-title ml-3">商城后台管理系统</h4>
    </div>
    <div class="layout-header-right">
      <button type="button" class="btn btn-light" @click="onLogout">退出</button>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

// 退出登录事件
const onLogout = () => {
  localStorage.removeItem('token')
  router.push('/login')
}
</script>

<style scoped lang="less">
.layout-header-container {
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid #eee;

  .layout-header-left {
    display: flex;
    align-items: center;

    .layout-header-left-img {
      width: 40px;
      height: 40px;
    }

    .layout-header-left-title {
      margin: 0;
      font-size: 18px;
      color: #333;
    }

    .ml-3 {
      margin-left: 15px;
    }
  }

  .layout-header-right {
    .btn {
      padding: 8px 16px;
      border: 1px solid #ddd;
      border-radius: 4px;
      cursor: pointer;
      transition: all 0.3s;

      &.btn-light {
        background: #fff;
        color: #666;

        &:hover {
          background: #f5f5f5;
        }
      }
    }
  }
}
</style>